// $Id$
// Copyright (c) 2008 Phloeme - Tous droits rservs.
package com.aticsi.blankapp.data.template.dao.hibernate;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.aticsi.blankapp.data.template.dao.ITemplateDAO;
import com.aticsi.blankapp.data.template.entities.TemplateEntity;

/**
 * <p>
 * Description : .
 * </p>
 * 
 * @author $Author$
 * @version $Revision$
 */
@Repository(value = "templateDAO")
public class TemplateDAOImpl implements ITemplateDAO {
	// ~ Variables membres
	// //////////////////////////////////////////////////////

	/**
	 * Mthode : .
	 * 
	 * @param pDozerMapper
	 */

	private static final org.apache.commons.logging.Log LOGGER = org.apache.commons.logging.LogFactory
			.getLog(TemplateDAOImpl.class);

	// ~ Methodes
	// ///////////////////////////////////////////////////////////////

	/** */
	private SessionFactory mSessionFactory;

	/**
	 * Methode : .
	 * 
	 * @param pC
	 */
	public void creerClient(final TemplateEntity pEntity) {

		mSessionFactory.getCurrentSession().save(pEntity);
	}

	/**
	 * Methode : .
	 * 
	 * @param pId
	 * 
	 * @return
	 */
	public TemplateEntity rechercherById(final int pId) {
		final TemplateEntity vTemplateEntity = (TemplateEntity) mSessionFactory
				.getCurrentSession().load(TemplateEntity.class, pId);

		return vTemplateEntity;
	}

	/**
	 * Methode : .
	 * 
	 * @param pSessionFactory
	 */
	@Autowired
	public void setSessionFactory(final SessionFactory pSessionFactory) {
		if (LOGGER.isDebugEnabled()) {
			LOGGER.debug("\n  On set la ssion factory  \n");
		}
		mSessionFactory = pSessionFactory;
	}

	/**
	 * Methode : .
	 * 
	 * @param pC
	 */
	public void updateClient(final TemplateEntity pEntity) {

		mSessionFactory.getCurrentSession().update(pEntity);
	}
}
